<script setup>
import { ref, defineProps, onMounted, watch } from 'vue'

const props = defineProps({
    title: {
        type: String,
        default: '热门文章'
    },
    contents: {
        type: Array,
        default: [{ "articleImg": "/vite.svg", "title": "Vite + Vue", "views": "1000","articleId":"" }]
    }
})
const toArticle=(url)=>{

}

</script>

<template>
    <div class="min-card1">
        <div class="m-title">
            <span>{{ title }}</span>
            <div>
                <p></p>
                <p></p>
            </div>
        </div>
        <div class="m-content" v-for="(item, index) in contents" :key="index" @click="$router.push('/articleDetail/'+item.articleId)">
            <li>
                <img :src="item.articleImg" alt="">
                <div>
                    <p>{{ item.title }}</p>
                    <span>{{ item.views }} views</span>
                </div>
            </li>
        </div>
    </div>
</template>

<style lang="scss" scoped>
@keyframes cardIn {
    0% {
        transform: translate(0, -20%);
    }
    100% {
        transform: translate(0, 0);
    }
}
.min-card1 {
    padding: 16px;
    min-width: 220px;
    width: 250px;
    border-radius: 5px;
    box-shadow: 0 0 2px rgba(0, 0, 0, .2);
    display: flex;
    flex-direction: column;
    background-color: #fff;
    transition: all .3s;
    margin-bottom: 16px;
    animation: cardIn .3s ease-in-out;
}

/* 标题开始 */
.min-card1 .m-title {
    color: #777777;
}

.min-card1 .m-title div {
    display: flex;
    align-items: center;
    justify-content: left;
    margin-bottom: 8px;
}

.min-card1 .m-title span {
    font-size: 14px;
}

.min-card1 .m-title>div> :first-child {
    flex: 1;
    height: 3px;
    background-color: red;
    width: 60px;
    margin-top: 10px;
}

.min-card1 .m-title>div>p:last-child {
    margin-top: 10px;
    flex: 3;
    height: 3px;
    border-bottom: 1px solid #999;
}

/* 标题结束 */
/* 内容开始 */
.m-content {
    display: flex;
    justify-content: left;
    flex-direction: column;

}

.m-content>li {
    display: flex;
    align-items: center;
    justify-content: left;
    cursor: pointer;
}

.m-content>li>img {
    width: 50px;
    height: 50px;
    border-radius: 5px;
    margin: 4px 6px;
}

.m-content li div {
    height: 50px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: left;
}

.m-content li div p {
    font-size: 12px;
    color: #777777;
}

.m-content li div span {
    font-size: 12px;
    color: #999;
}

.m-content>li:hover img {
    transition: all .3s linear;
    transform: translate(-5px, -5px) scale(1.2);
}

@keyframes change {
    0% {
        transform: translate(100px, 0);
    }

    100% {
        transform: translate(0, 0);
    }
}

.min-card1 .m-content li {
    animation: change .3s linear;
}
</style>